package com.quanyan.comment.model.vo;

import java.io.Serializable;

/**
 * Created by Administrator on 2016/5/5.
 */
public class Image implements Serializable{
    private static final long serialVersionUID = -3178762704383883458L;
    private static final String COMMON_TAIL_FIX = "!bac";
    private static final String THUMB_TAIL_FIX = "!thumb";
    private int id;//:图片id,
    private int state;//:图片状态,0->close 1->open,
    private int isMain;//:图片类型,1->活动海报,2->场馆图片,3->用户照片(详细看 Constants)
    private String thumbnailUrl = "";//:缩略图,
    private String imageUrl = "";//:原图

    public Image() {
    }

    public Image(String imageUrl) {
        if (imageUrl != null) {
           /* this.imageUrl = imageUrl;
            Pattern pattern = Pattern.compile(".+\\.(png|jpg|jpeg|gif)(![a-zA-Z]{3,10})$");
            Matcher matcher = pattern.matcher(imageUrl);
            if (matcher.matches()) {
                imageUrl = imageUrl.replaceAll("(![a-zA-Z]{3,10})$", COMMON_TAIL_FIX);
            } else {
                imageUrl += COMMON_TAIL_FIX;
            }
            this.imageUrl = imageUrl;
            setThumbnailUrl(this.imageUrl);*/
            this.imageUrl = imageUrl;
        }
    }

    public Image(int id, String imageUrl) {
        this(imageUrl);
        this.id = id;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getState() {
        return state;
    }

    public void setState(int state) {
        this.state = state;
    }

    public int getIsMain() {
        return isMain;
    }

    public void setIsMain(int isMain) {
        this.isMain = isMain;
    }

    public String getThumbnailUrl() {
        return thumbnailUrl;
    }

    public void setThumbnailUrl(String thumbnailUrl) {
        this.thumbnailUrl = thumbnailUrl.replaceAll("(![a-zA-Z]{3,10})$",THUMB_TAIL_FIX);
    }

    public String getImageUrl() {
        return imageUrl;
    }

    public void setImageUrl(String imageUrl) {

    }
}
